<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const ladder = {
        num: 0,
        up() {
          this.num++;
          return this; //ladder
        },
        down() {
          this.num--;
          return this;
        },
        read() {
          console.log(this.num); //显示num
          return this;
        },
      };
      // 对象中各个方法返回对象本身
      ladder.up().up().up().down().up().read().up().read();
      // ladder.up(); //+1
      // ladder.down(); //-1
      // ladder.read();
    </script>
  </body>
</html>
